import request from "@/utils/request";
import type { Create_User, UserLogin, Update } from "@/types/user"




enum USERAPI {
    REGISTER = '/user',
    LOGIN = '/user/login',
    LOGIN_OUT = '/user/loginout',
    FORGET = '/user/forget',
    UPDATE = "/user/update"
}


export const Creact_User = (data: Create_User) => request({
    method: "POST",
    url: USERAPI.REGISTER,
    data,

})

export const User_Login = (data: UserLogin) => request({
    method: "POST",
    url: USERAPI.LOGIN,
    data
})
export const Forget_pass = (qqnumber: string) => request({
    method: "POST",
    url: USERAPI.FORGET,
    data: {
        qqnumber,
    }

})
export const User_login_out = () => request({
    method: "POST",
    url: USERAPI.LOGIN_OUT
})
//上传头像
export const User_up_avatar = (data: any) => request({
    method: "POST",
    url: "/upload/user",
    data,
    headers: {
        // 表示上传的是文件,而不是普通的表单数据
        'Content-Type': 'multipart/form-data'
    }
})

export const User_update = (data: Update) => request({
    method: "POST",
    url: USERAPI.UPDATE,
    data
})

//测试接口
export const testapi = () => request({
    method: "GET",
    url: "/user/test"
})
